package com.itheima.d0_test;

import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Test {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        System.out.println("请输入一段字符");
        String str = scanner.nextLine();
        while (str.length()<10){
            System.out.println("请重新输入");
            str = scanner.next();
        }

         String s = str.substring(2, 7);
        System.out.println(s);

         char[] chars = s.toCharArray();

        Arrays.sort(chars);


         HashMap<Character, Integer> map = new HashMap<>();

        for (int i = 0; i < chars.length; i++) {
                    Character c= chars[i];

                    Integer num = map.get(c);

                    if(!map.containsValue(num)){
                        map.put(c,1);

                    }else {
                        num++;
                        map.put(c,num);
                    }
        }

         Set<Map.Entry<Character, Integer>> entries = map.entrySet();
        for (Map.Entry<Character, Integer> entry : entries) {
            System.out.println(entry.getKey()+":"+entry.getValue());

        }
    }
}
